﻿// Copyright 2012 Stuart Turner
// Licensed under the Apache License, Version 2.0 [http://www.apache.org/licenses/LICENSE-2.0]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace Complete.Data.Linq.Expressions
{
	internal class ColumnReplacer : CompleteExpressionVisitor
	{
		private ColumnReplacer()
		{
		}

		protected override Expression VisitColumn(ColumnExpression column)
		{
			return CompleteExpression.Column(column, column.Name, column.Alias);
		}

		protected override Expression VisitSelect(SelectExpression select)
		{
			return select;
		}

		public static Expression ReplaceColumns(Expression expr)
		{
			var cr = new ColumnReplacer();
			return cr.Visit(expr);
		}

	}
}
